<template>
	<view>
		<u-navbar title="商品评论" :autoBack="true" :placeholder="true"></u-navbar>
		<!-- 评论 -->
		<view class="commentCard card" v-for="(item,index) in messList" :key="index">
			<view class="commentCard-center">
				<view class="user">
					<image class="picture" :src="item.user.avatar" mode=""></image>
					<view class="userRight">
						<view class="userRow">
							<view class="userName u-line-1">{{item.user.nickname}}</view>
							<text>{{item.createtime}}</text>
						</view>
						<u-rate :value="item.com_level" active-color="#FFC729" inactive-color="#F0F2F5" allowHalf
							readonly>
						</u-rate>
					</view>
				</view>
				<view class="comment">
					{{item.com_text}}
				</view>
			</view>
			<view class="commentCard-below">
				<VideoImg :url="item2" v-for="(item2,index2) in item.com_images" :key="index2" />

				<!-- 		<image :src="item2" @click="previewSqs(item2,item.com_images)" :data-src="item2"
					v-for="(item2,index2) in item.com_images" :key="index2"></image> -->
			</view>
		</view>
	</view>
</template>

<script>
	import VideoImg from '@/components/VideoImg/VideoImg.vue'
	export default {
		data() {
			return {
				id: null,
				messList: [],
				last_page: null, // 总页数
				page: 1, //当前页
			};
		},
		components: {
			VideoImg
		},
		onLoad(option) {
			this.id = option.id
			this.getMessGoods()
		},
		async onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				let res = await this.$api.getMessGoods({
					id: this.id,
					page: this.page,
					total: 5
				})
				this.messList.push(...res.data.data)
			} else {
				this.$u.toast('已经到底了！')
			}
		},
		methods: {
			// 获取评论
			async getMessGoods(id) {
				let res = await this.$api.getMessGoods({
					id: this.id,
					page: 1,
					total: 5
				})
				this.messList = res.data.data
				this.last_page = res.data.last_page
			}
		}
	}
</script>
<style>
	page {
		box-sizing: border-box;
		padding-bottom: 100rpx;
	}
</style>
<style lang="scss" scoped>
	.commentCard {

		&-center {

			.user {
				display: flex;
				justify-content: space-between;
				align-items: center;
				color: rgba(0, 0, 0, 0.55);
				font-size: 26rpx;
				font-weight: 400;



				.picture {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					margin-right: 16rpx;
				}

				.userRight {
					flex: 1;

					.userRow {
						margin-left: 4rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
					}

					.userName {
						width: 250rpx;
					}
				}
			}

			.comment {
				margin-top: 16rpx;
				// height: 80rpx;
			}
		}

		&-below {
			margin-top: 16rpx;
			display: grid;
			grid-gap: 15rpx;
			grid-template-columns: repeat(3, 1fr);
			// display: flex;
			// justify-content: space-between;
			// align-items: center;
			// flex-wrap: wrap;
			// height: 210rpx;

			image {
				width: 210rpx;
				height: 210rpx;
				border-radius: 16rpx;

			}
		}

	}
</style>
